    
require "colorize"
Colorize.on_tty_only!        # Makes Colorize.enabled true if and only if     
                             # both of STDOUT.tty? and STDERR.tty? are true
                             # and the tty is not considered a dumb terminal.



module Tocolor
#@@toblue = ->(st: String) { st.colorize.on(:black).fore(:blue)}
#tored = ->(st: String) { st.colorize.on(:black).fore(:red)}
#
#def toblue(st)
#    st153 =st.to_s()
# ->(st153: String) { st.colorize.on(:black).fore(:blue)}
#end

AColorSym = %i(red green yellow blue magenta cyan light_gray light_red light_green light_yellow light_blue light_magenta light_cyan white)
IAsize= AColorSym.size()
AModeSym = %i(zero bold underline bright )
IAmo = AModeSym.size()

def to_cm(st : _ = "", colorSym : Symbol = :green, modeSym : Symbol = :bright)
    st.to_s.colorize.on(:black).fore(colorSym).mode(modeSym) 
end

def to_cmi(st : _ = "", colorSi : Int32 = 1, modeSi : Int32 = 0)
    ci = colorSi % IAsize
    symCi = AColorSym[ci]
    qt = (colorSi / IAsize).to_i()
    mi = modeSi % IAmo
    mi2 = qt % IAmo
    mi = mi2
    if mi == 0
        symCi = AColorSym[ci]
        st.to_s.colorize.on(:black).fore(symCi)
    else
        symMi = AModeSym[mi]
        st.to_s.colorize.on(:black).fore(symCi).mode(symMi)
        
    end
end


end

#Available text decorations are:
#
#:bold
#:bright
#:dim
#:underline
#:blink
#:reverse
#:hidden

#Available colors are:
#
#:default
#:black
#:red
#:green
#:yellow
#:blue
#:magenta
#:cyan
#:light_gray
#:dark_gray
#:light_red
#:light_green
#:light_yellow
#:light_blue
#:light_magenta
#:light_cyan
#:white


